package com.atguigu.day05.HomeWork;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/4 19:27
 * @注释 判断数组中的元素值是否对称
 */
public class HomeWork5 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,4,3,2,1};
        int[] arr2 = {1,2,1,3,5,4,3,5,1};
        boolean b = true;
        for (int i = 0; i < arr.length / 2; i++) {
            if(arr[i] != arr[arr.length - i - 1]) {
                b = false;
                break;
            }
        }
        System.out.println("arr[1,2,3,4,5,4,3,2,1]是否对称:" + b);

        b = true;
        for (int i = 0; i < arr2.length / 2; i++) {
            if(arr2[i] != arr[arr2.length - i - 1]) {
                b = false;
                break;
            }
        }
        System.out.println("arr2[1,2,1,3,5,4,3,5,1]是否对称:" + b);
    }
}
